package com.example.demo.service.impl;

import com.example.demo.compent.RedisUtil;
import com.example.demo.po.User;
import com.example.demo.service.UserAsynServiceI;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserAsynServiceImpl implements UserAsynServiceI {

    private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(UserAsynServiceImpl.class);

    @Resource
    private RedisUtil redisUtil;

    @Override
    public User getByCardNo(String cardNo) {
        return null;
    }

    @Override
    @Async
    public void add(User user )  {
        try {

            Thread.sleep(5000);
        }catch (Exception e){
            LOG.info(e.getLocalizedMessage());
        }
        LOG.info("add");
        redisUtil.set(user.getCardNo(), user);

    }
}
